**********************************
******Figure 1: Raw data
**********************************
global user "`c(username)'"
global dirdata "C:\Users\\$user\Dropbox\CCT BJP\data"
global dir1  "$dirdata\Final data"
global dir2  "$dirdata\Results\graphs"
cd "$dir2"

use "$dir1\pooled_hh.dta", clear

tab min_schooling
drop bjp
g bjp=nbjp>0
replace bjp=. if nbjp==.

***** Compliance: Figure 1

preserve
collapse bjp nbjp if min_schooling>=1 & min_schooling<9 & year>2006, by(ltau)
tw connected bjp ltau if ltau>-5, sort , xtitle(Time to treatment) ytitle(Prob. of Cash Reception) title(A-Program participation) xline(-1)   legend(off) xlabel(#5) graphregion(color(white))
gr export Figure1_left.eps, replace
tw connected nbjp ltau if ltau>-5, sort , xtitle(Time to treatment) ytitle(# of beneficiaries) title(B-# of beneficiaries) xline(-1)   legend(off) xlabel(#5) graphregion(color(white))
gr export Figure1_right.eps, replace
restore


**** Graphical evidence labor - Figure 2

egen w_hoursw_head=rowtotal(w_hoursw_m w_hoursw_p)

gen work_head=w_hoursw_head>0 
replace work_head=. if work_m==. & work_p==.

preserve
keep if tau>-5  

collapse work_head w_hoursw_head work_m work_p [w=factor] if min_schooling>=1 & min_schooling<9 , by(tau)

foreach x in  w_hoursw_head work_head work_m work_p {
sum `x' if tau<=-1
replace `x'=`x'-r(mean)
}


tw connected work_head  tau if tau<=-1 , sort msize(vlarge) mstyle(circle) lpattern(dash) lwidth(mthick) || connected work_head tau if tau>=0 , sort msize(vlarge) mstyle(circle) lpattern(dash) lwidth(mthick)xline(-1) xtitle(Time to treatment) ytitle(Prob.) title(A-Employment) legend(off)  graphregion(color(white)) xlabel(#8)  
gr export Figure2_left.eps, replace

tw connected w_hoursw_head  tau if tau<=-1 , sort msize(vlarge) mstyle(circle) lpattern(dash) lwidth(mthick) || connected w_hoursw_head tau if tau>=0 , sort msize(vlarge) mstyle(circle) lpattern(dash) lwidth(mthick)xline(-1) xtitle(Time to treatment) ytitle(Hours) title(B-Weekly hours) legend(off)  graphregion(color(white)) xlabel(#8)  
gr export Figure2_right.eps, replace


******* Figure 4

tw connected work_m  tau if tau<=-1 , sort msize(vlarge) mstyle(circle) lpattern(dash) lwidth(mthick) || connected work_m tau if tau>=0 , sort msize(vlarge) mstyle(circle) lpattern(dash) lwidth(mthick)xline(-1) xtitle(Time to treatment) ytitle(Prob.) title( A-Females) legend(off)  graphregion(color(white)) xlabel(#8)  
gr export Figure4_left.eps, replace

tw connected work_p  tau if tau<=-1 , sort msize(vlarge) mstyle(circle) lpattern(dash) lwidth(mthick) || connected work_p tau if tau>=0 , sort msize(vlarge) mstyle(circle) lpattern(dash) lwidth(mthick)xline(-1) xtitle(Time to treatment) ytitle(Prob.) title(B-Males) legend(off)  graphregion(color(white)) xlabel(#8)  
gr export Figure4_right.eps, replace
restore
